package cn.wolfcode.trip.app.controller;

import cn.wolfcode.trip.base.domain.Strategy;
import cn.wolfcode.trip.base.domain.StrategyCatalog;
import cn.wolfcode.trip.base.query.StrategyQuery;
import cn.wolfcode.trip.base.service.IStrategyCatalogService;
import cn.wolfcode.trip.base.service.IStrategyService;
import com.github.pagehelper.PageInfo;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

/**
 * Created by 13925 on 2018/11/6.
 */
@RestController
@RequestMapping("/strategies")
public class StrategiesController {

    @Autowired
    private IStrategyService strategyService;

    @Autowired
    private IStrategyCatalogService catalogService;

    @GetMapping
    public PageInfo list(StrategyQuery qo) {
        return strategyService.query(qo);
    }

    @GetMapping("/{strategyId}/catalogs")
    public List<StrategyCatalog> listCatalogs(@PathVariable Long strategyId) {
        return catalogService.getCatalogByStrategyId(strategyId);
    }


    @GetMapping("/{strategyId}")
    public Strategy list(@PathVariable Long strategyId) {
        return strategyService.get(strategyId);
    }


}
